package com.wyp.service.impl;

import com.wyp.mapper.*;
import com.wyp.pojo.Admins;
import com.wyp.service.AdminsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AdminsServiceImpl implements AdminsService {

    @Autowired
    private AdminsMapper adminsMapper;

    @Autowired
    private ExamineesMapper examineesMapper;

    @Autowired
    private QuestionsMapper questionsMapper;

    @Autowired
    private ScoresMapper scoresMapper;

    @Autowired
    private TestpapersMapper testpaperMapper;

    @Override
    public Map<String, Integer> GetDataCount() {
        Map<String, Integer> count = new HashMap<>();
        count.put("AdminCount", adminsMapper.GetAdminCount());
        count.put("ExaminesCount", examineesMapper.GetStuCount());
        count.put("QuestionCount", questionsMapper.GetQuestionsCount());
        count.put("ScoreCount", scoresMapper.GetScoresCount());
        count.put("TestpaperCount", testpaperMapper.GetTestpapersCount());
        return count;
    }

    @Override
    public Admins findByAdminaccount(String adminaccount) {
        return adminsMapper.findByAdminaccount(adminaccount);
    }

    @Override
    public List<Admins> qureyAllAdmins() {
        return adminsMapper.qureyAllAdmins();
    }

    @Override
    public boolean addAdmin(Admins admin) {
        return (adminsMapper.addAdmin(admin) != 0);
    }

    @Override
    public boolean updateAdmin(Admins admin) {
        return (adminsMapper.updateAdmin(admin) != 0);
    }

    @Override
    public boolean deleteAdmin(Integer id) {
        return (adminsMapper.deleteAdmin(id) != 0);
    }
}
